import Message from "./fv-index.vue";
import { createApp } from "vue";

// let count = 0;
let timer, app, el;
export function message(options) {
  const close = () => {
    el.remove();
  };
  // if(count >= 1) return ;
  if (document.querySelector("div.fv-message")) {
    app.count++
  } else {
    el = document.createElement("div");
    el.classList.add("fv-message");

    app = createApp(Message, {
      ...options,
      close,
    }).mount(el)

    console.log(app)
    document.body.appendChild(el);
  }

  clearTimeout(timer);
  timer = setTimeout(() => {
    close();
  }, 3000);
}

export const FVMessage = Message;
